/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */
package org.jeecg.modules.middleware.rabbitmq.gen.handler.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.util.DictUtil;
import org.jeecg.modules.middleware.message.websocket.WebSocket;
import org.jeecg.modules.middleware.rabbitmq.gen.EnumGenHandler;
import org.jeecg.modules.middleware.rabbitmq.gen.handler.IGenMqHandle;
import org.jeecg.modules.wlhy.report.ShippingNoteApiAlct56Service;
import org.jeecg.modules.wlhy.report.ShippingNoteTosApiService;
import org.jeecg.modules.wlhy.shipping.entity.HyShippingNote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 创建运单-队列消息接收方法
 *
 * @author duanlikao
 * @created 2022/3/30
 */
@Service
public class DaPingHandler implements IGenMqHandle {

    private static final Logger LOGGER = LoggerFactory.getLogger(DaPingHandler.class);


    @Autowired
    private ShippingNoteApiAlct56Service shippingNoteApiAlct56Service;

    @Resource
    private WebSocket webSocket;
    @Autowired
    private DictUtil dictUtil;


    @Override
    public String getHandlerName() {
        return EnumGenHandler.DAPING.getHandlerName();
    }

    @Override
    public void handle(String channel, String msg) {
        try {
            HyShippingNote hyShippingNote = JSONObject.parseObject(msg, HyShippingNote.class);

            //TODO Delete at 2023-04-24 for 这有啥用，数据到大屏么，控制台报错先删了。
            //JSONObject jsonObject = dictUtil.parseObjectDict(hyShippingNote);
//            webSocket.sendOneMessage("e9ca23d68d884d4ebb19d07889727dae", JSON.toJSONString(jsonObject));

//            webSocket.sendOneMessage("e9ca23d68d884d4ebb19d07889727dae", hyShippingNote.toString());


        } catch (Exception e) {
            LOGGER.error("[消费消息队列-创建运单-数据失败，失败信息:{}]", e.getMessage());
        }
    }
}
